package com.audaque.springboot.foshanupload.web.register;

import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.http.HttpStatus;

/**
 * Description: 不推荐
 */
public class MyErrorPageRegister implements ErrorPageRegistrar {

    @Override
    public void registerErrorPages(ErrorPageRegistry registry) {
        // 根据不同的错误状态，返回指定的错误页面
        ErrorPage errorPage400 = new ErrorPage(HttpStatus.BAD_REQUEST, "/400");
        ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND, "/404");
        ErrorPage errorPage500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500");
        // 注册
        registry.addErrorPages(errorPage400, errorPage404, errorPage500);
    }
}
